using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using THSLib;using THSERP.BaseProvider;
using DevExpress.XtraGrid.Views.Grid;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using System.Windows.Forms;
using DevExpress.XtraGrid.Columns;
using System.Drawing;

namespace THSERP.Modules.CompanyConstant
{
    public partial class PaymentTypeGridControl : THSGridControl
    {
        public override void InitGridControlDataSource()
        {
            base.InitGridControlDataSource();
            ADConfigValuesController objConfigValuesController = new ADConfigValuesController();
            DataSet ds = objConfigValuesController.GetADConfigValuesByGroup(ADConfigValueUtility.ADConfigValuePaymentMethod);

            //Add checkbox to choice payment type_Hieu.nguyen_12/04/2010
            DataColumn checkColumn = new DataColumn("Choice", typeof(bool));
            ds.Tables[0].Columns.Add(checkColumn);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (row["ADConfigKeyDesc"].ToString() == String.Empty || row["ADConfigKeyDesc"].ToString() == "0")
                    row["Choice"] = false;
                else
                    row["Choice"] = true;
            }

            this.DataSource = ds.Tables[0];
            this.RefreshDataSource();
        }

        protected override GridView InitializeGridView()
        {
            GridView gridView = new GridView();
           
            gridView.OptionsSelection.EnableAppearanceFocusedCell = false;
            gridView.OptionsSelection.EnableAppearanceFocusedRow = false;
            gridView.GridControl = this;
            gridView.Columns.AddVisible("ADConfigText");
            gridView.Columns.AddVisible("Choice");
            gridView.Columns["ADConfigText"].OptionsColumn.AllowEdit = false;
            gridView.Columns["ADConfigText"].AppearanceCell.BackColor = Color.WhiteSmoke;
            gridView.OptionsView.ShowColumnHeaders = false;
            gridView.OptionsView.ShowGroupPanel = false;

            return gridView;
        }
    }
}
